package org.crazyit.album.web;

import java.io.*;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.crazyit.album.web.base.BaseServlet;

@WebServlet(urlPatterns = "/pageLoad")
public class PageLoadServlet extends BaseServlet {
    public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        response.setContentType("text/javascript;charset=gbk");
        PrintWriter out = response.getWriter();
        HttpSession session = request.getSession(true);
        String name = (String) session.getAttribute("curUser");
        if (name != null) {
            out.println("$('#noLogin').hide()");
            out.println("$('#hasLogin').show()");
            out.println("onLoadHandler();");
            String curImg = (String) session.getAttribute("curImg");
            if (curImg != null) {
                out.println("$('#show').attr('src' , 'uploadfiles/" + curImg + "');");
            }
        }
    }
}
